package org.dut.community.task;

import lombok.extern.slf4j.Slf4j;
import org.dut.community.service.DiscussPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class PostReadCountSyncTask {
    @Autowired
    private DiscussPostService discussPostService;

    @Scheduled(initialDelay = 1000 * 60 * 5,fixedRate = 1000 * 60 * 5)
    public void syncPostReadCount(){
        // 5min执行一次同步
        log.info("开始同步帖子阅读量");
        discussPostService.updatePostReadCountInDatabase();
        log.info("结束同步帖子阅读量");
    }
}
